package src.com.doit.Demo05;

import java.util.ArrayList;

public class test {
    public static void main(String[] args) {
        ArrayList<Cat> list = new ArrayList<>();
        Cat [] a = new Cat[3];

        Cat cat1 = new Cat();
        cat1.setName("TOM");
        cat1.setColor("宝石蓝");
        a[0]=cat1;

        Cat cat2 = new Cat("Jerry","棕色");
        a[1]=cat2;

        Cat cat3 = new Cat("巴尔札特","黑色");
        a[2]=cat3;

        for (int i = 0; i < a.length; i++)//遍历小猫
        {
            Cat b = new Cat();
            b=a[i];
            System.out.println(b.getName()+" "+b.getColor());
            b.catching();
        }
        jiHe(list);
    }
    public static void jiHe( ArrayList<Cat>list)
    {
        Cat a = new Cat();
        a.setName("今晚打脑斧");
        a.setColor("黄色");
        list.add(a);

        Cat b = new Cat("午夜狼嚎","灰色");
        list.add(b);

        Cat c = new Cat("加菲猫","棕黄");
        list.add(c);

        for (int i = 0; i < list.size(); i++) {
            Cat d = new Cat();
            d=list.get(i);
            System.out.println(d.getName()+" "+d.getColor());
            d.catching();
        }
    }
}
